<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <title>氦闪</title>
    <link rel="stylesheet" href="__PUBLIC__/web/css/city-picker.css">
    <link rel="stylesheet" href="__PUBLIC__/web/css/public.css">
    <link rel="stylesheet" href="__PUBLIC__/web/css/address.css">
</head>
<body>
<header>
    <include file="Index/header"/>
</header>


<include file="Index/left"/>

<section>
    <div class="ly-content ly-cent">
        <div class="ly-title">
            选择 / 确认收货地址
        </div>
        <div class="ly-address">
            <h1>选择已有的地址  <a href="javascript:;" class="ly-add">添加地址</a></h1>
            <ul class="ly-list">
                <volist name="lists" id="vo">
                    <li>
                        <label for="chek1">
                            <input type="radio" name="chek" addr_id="{$vo.id}" id="chek1"/>
                            <h4>{$vo.fullname} <span>{$vo.phone}</span></h4>
                            <p>{$vo.provice}{$vo.city}{$vo.country}{$vo.address}</p>
                        </label>
                    </li>
                </volist>

                <!--<li>
                    <label for="chek2">
                        <input type="radio" name="chek" id="chek2"/>
                        <h4>氦闪 <span>18600256472</span></h4>
                        <p>四川省成都市锦江区琉璃路25号四川省成都市锦江区琉璃路25号四川省成都市锦江区琉璃路25号四川省成都市锦江区琉璃路25号</p>
                    </label>
                </li>-->
            </ul>

            <div class="ly-submit">
                <a href="javascript:;">提交订单</a>
            </div>
        </div>
        <!--<div class="ly-address ly-pas">
            <h1>快递信息</h1>
            <div class="ly-intro">
                <img src="__PUBLIC__/web/images/icon_sf.png"/>
                <p>所有商品默认使用顺丰快递进行派送</br> 若有疑问请联系氦闪 </p>
            </div>
            &lt;!&ndash;<h4>中国大陆地区互寄：1-2天，部分偏远地区加0.5-1天。</h4>&ndash;&gt;
            &lt;!&ndash;<h4> 中国大陆地区至港澳台地区：1.5-2.5天，部分偏远地区加0.5-1天。</h4>&ndash;&gt;
        </div>-->
    </div>
    <include file="Index/footer"/>
</section>

<div class="ly-layer">
    <div class="ly-cont">
        <form action="" id="address-form">
            <ul class="ly-list">
                <li>
                    <input type="text" name="city" id="city" class="ly-input" placeholder="请选择省市区"/>
                </li>
                <li>
                    <input type="text" name="address" class="ly-input" placeholder="详细地址"/>
                </li>
                <li>
                    <input type="text" name="fullname" class="ly-input" placeholder="收货人姓名"/>
                </li>
                <li>
                    <input type="text" name="phone" class="ly-input" placeholder="手机号码" maxlength="11"/>
                </li>
                <li>
                    <a class="ly-submit-up">保存</a>
                </li>
            </ul>
        </form>

        <div class="ly-close"><img src="__PUBLIC__/web/images/icon_close.png"/></div>
    </div>
</div>

<div class="ly-menu-nav" data-id="1">
    <img src="__PUBLIC__/web/images/icon_menu.png" />
</div>
</body>
<script src="__PUBLIC__/web/js/jquery.min.js"></script>
<script src="__PUBLIC__/web/js/reg.js"></script>
<script src="__PUBLIC__/web/js/city-picker.data.js"></script>
<script src="__PUBLIC__/web/js/city-picker.js"></script>
<script src="__PUBLIC__/web/js/public.js"></script>
<script>
$(".ly-submit").on("click","a",function () {
    var list= $('input:radio[name="chek"]:checked').val();
    if(list==null){
        alert("请选择收货地址!");
        return;
    }
    var addr_id = $('input:radio[name="chek"]:checked').attr('addr_id');

    $.ajax({
        url: "{:U('createOrder')}",
        dataType:"json",
        data:{addr_id:addr_id, sale_code: "{$sale_code}"},
        type:'POST',
        async:true,
        beforeSend:function(){

//                $("body").showLoading();
        },
        success:function(rst){
            console.log(rst);
            if(rst.code == '200') {
                // alert('成功');
                var info = rst.datas;
                window.location.href = "{:U('pay')}"+'/order_id/'+info.order_id;
            } else {
                alert(rst.mark);
            }
        },
        error: function(){
//                $("body").hideLoading();
//                    alert("错误");
        }

    });

    // window.location.href = "{:U('pay')}"+'/addr_id/'+addr_id;
})

$("#city").click(function (e) {
    SelCity(this, e);
    console.log("inout", $(this).val(), new Date())
});

$(".ly-add").on("click",function () {
    $(".ly-layer").show();
})
$(".ly-close").on("click",function () {
    $(".ly-layer").hide();
});
    $('.ly-submit-up').click(function () {
        var formData = $('#address-form').serializeArray();
        $.ajax({
            url: "{:U('addAddr')}",
            dataType:"json",
            data:{formData:formData},
            type:'POST',
            async:true,
            beforeSend:function(){

//                $("body").showLoading();
            },
            success:function(rst){
                console.log(rst);
                if(rst.code == '200') {
                    window.location.reload();
                } else {
                    alert(rst.msg);
                }
            },
            error: function(){
//                $("body").hideLoading();
//                    alert("错误");
            }

        });
    })

</script>
</html>





